package com.example.administrator.exkotlin.ui.fragment

import android.app.Fragment
import android.content.Context
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import com.example.administrator.exkotlin.R
import kotlinx.android.synthetic.main.left_fragment.*

class LeftFragment : BaseFragment() {

    lateinit var mContext: Context
    public var mlefLeftFargmentClickListtner: LeftFargmentClickListtner? = null

    public interface LeftFargmentClickListtner {
        fun leftCheck()
    }

    private fun initDatas() {
        btn_left_ragment.setOnClickListener {
            if (mlefLeftFargmentClickListtner != null) {
                Toast.makeText(mContext, "FragmentChange", Toast.LENGTH_SHORT).show()
                mlefLeftFargmentClickListtner?.leftCheck()
            } else {
                Toast.makeText(mContext, "请设置Activity监听", Toast.LENGTH_SHORT).show()
            }
        }
    }

    override fun onAttach(context: Context?) {
        super.onAttach(context)
        if (context != null) {
            mContext = context
        }

    }

    override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        return inflater?.inflate(R.layout.left_fragment, container, false)
    }


    override fun onActivityCreated(savedInstanceState: Bundle?) {
        super.onActivityCreated(savedInstanceState)
        initDatas()
    }

}